package nl.ceasaro.poker.texasHoldEm.game;

import nl.ceasaro.playingcards.Card;
import nl.ceasaro.poker.ranking.PokerHand;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: cees
 * Date: Apr 12, 2007
 * Time: 10:44:56 PM
 * <p/>
 * A player at a texas hold'em poker table. A player
 *
 * @todo implement a Wallet in which a the player keeps it's chips.
 */
public class TexasPlayer
{
   enum actions
   {
      CHECK, FALLED, BET, CALL, RAISE
   }

   private String name;
   private Card card1;
   private Card card2;
   private PokerHand pokerHand;

   //private Wallet wallet;
   public TexasPlayer(String playerName)
   {
      this.name = playerName;
   }

   public String getName()
   {
      return name;
   }

   public void setName(String name)
   {
      this.name = name;
   }

   public void dealCards(Card card1, Card card2)
   {
      this.card1 = card1;
      this.card2 = card2;
   }

   public Card getCard1()
   {
      return card1;
   }

   public Card getCard2()
   {
      return card2;
   }

   public PokerHand getPokerHand()
   {
      return pokerHand;
   }

   public void setPokerHand(PokerHand pokerHand)
   {
      this.pokerHand = pokerHand;
   }

   public List<Card> getCards()
   {
      ArrayList<Card> cards = new ArrayList<Card>();
      if (getCard1() != null)
      {
         cards.add(getCard1());
      }
      if (getCard2() != null)
      {
         cards.add(getCard2());
      }
      return cards;
   }

   /**
    * removed the dealed cards from the player
    */
   public void reset()
   {
      card1 = null;
      card2 = null;
      pokerHand = null;
   }

   /**
    * @noinspection RedundantIfStatement
    */
   public boolean equals(Object o)
   {
      if (this == o)
      {
         return true;
      }
      if (o == null || getClass() != o.getClass())
      {
         return false;
      }

      TexasPlayer that = (TexasPlayer) o;

      if (name != null ? !name.equals(that.name) : that.name != null)
      {
         return false;
      }

      return true;
   }

   public int hashCode()
   {
      return (name != null ? name.hashCode() : 0);
   }

}
